/**
 * DataType interface
 *
 * @author Equipe SimPack 2004
 * @created Jun 7, 2004
 *
 * @modified Mar 7, 2007
 * @author adelaye
 * @author jprieur
 *
 * This interface is a format used by both GUI and TUI to communicate
 * informations about an element of the simulation to the Simulator
 *
 */

package kernel;
import java.io.*;

public abstract class DataType implements Serializable
{
   
    public final static Double UNDEFINED = Double.MIN_VALUE;
    

    /**
     * Checks the validity of the value within the given bounds
     * @param floor bound
     * @param ceiling bound
     * @param the value to check
     */
    boolean checkBounds(double min, double max, double value)
    {
	if(max==UNDEFINED && min==UNDEFINED)
	{
	    return true;
	}
	if(max==UNDEFINED)
        {
	    return (min <= value);
	}
	if(min==UNDEFINED)
	{
	    return (max >= value);
	}
	
	return (min <= value &&
		max >= value);
    }


    boolean checkBounds(int min, int max, int value)
    {
	if(max==UNDEFINED && min==UNDEFINED)
	{
	    return true;
	}
	if(max==UNDEFINED)
        {
	    return (min <= value);
	}
	if(min==UNDEFINED)
	{
	    return (max >= value);
	}	    
	return (min <= value &&
		max >= value);
    }

}
